package com.polaris.live.popup

import android.content.Context
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BottomPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.common.util.NavigationBarUtils
import com.polaris.live.databinding.PopupMagicLampTipsBinding
import com.polaris.live.utils.image.ImageUtils

/**
 *  MagicLampTipsPopup 神灯介绍
 * @author Created by 天晴 on 2024/11/25 19:18
 * @since 1.0.0
 **/
class MagicLampTipsPopup(
    context: Context,
) : BottomPopupView(context) {

    private lateinit var mBinding: PopupMagicLampTipsBinding
    override fun getImplLayoutId(): Int {
        return R.layout.popup_magic_lamp_tips
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = PopupMagicLampTipsBinding.bind(popupImplView)
        val lp = mBinding.bottom.layoutParams as ViewGroup.LayoutParams
        lp.height = NavigationBarUtils.getNavigationBarHeight(context)
        mBinding.bottom.layoutParams = lp
        mBinding.cancel.setOnSingleClickListener {
            dismiss()
        }

        Glide.with(context)
            .load(ImageUtils.imgPath("static/lamp/explain/explain1.png"))
            .into(mBinding.explainImg1)
        Glide.with(context)
            .load(ImageUtils.imgPath("static/lamp/explain/explain2.png"))
            .into(mBinding.explainImg2)
        Glide.with(context)
            .load(ImageUtils.imgPath("static/lamp/explain/explain3.png"))
            .into(mBinding.explainImg3)

    }


    companion object {

        fun show(
            context: Context,
        ) {
            XPopup.Builder(context)
                .isViewMode(false)
                .hasShadowBg(true)
                .moveUpToKeyboard(false)
                .isDestroyOnDismiss(true)
                .asCustom(MagicLampTipsPopup(context))
                .show()
        }

    }
}